/**
 * 
 */
package org.mhz.sit.service;

import java.util.List;

import javafx.collections.ObservableList;

import org.mhz.sit.dataaccess.ConfigureSpeakersDAO;
import org.mhz.sit.entity.BaseSpeaker;
import org.mhz.sit.entity.Speaker;
import org.mhz.sit.entity.SpeakerOffTopicOrder;
import org.mhz.sit.entity.SpeakerOrder;
import org.mhz.sit.util.DatabaseUtil;
import org.mhz.sit.util.SpeakerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Mahan
 *
 * Configure speakers service
 */
public class ConfigureSpeakersService implements SpeakerService
{
    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureSpeakersService.class);

    private ConfigureSpeakersDAO mConfigureSpeakersDAO = new ConfigureSpeakersDAO();
    
    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#getList()
     */
    @Override
    public List<Speaker> getList()
    {
        final List<Speaker> speakers = mConfigureSpeakersDAO.getAll();   
                
        return speakers;
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#addSpeaker(org.mhz.sit.entity.Speaker, javafx.collections.ObservableList)
     */
    @Override
    public void addSpeaker(final Speaker aSpeaker,
                           final ObservableList<Speaker> aObservableList)
    {
        DatabaseUtil.addSpeaker(aSpeaker, aObservableList);
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#updateSpeaker(org.mhz.sit.entity.Speaker)
     */
    @Override
    public void updateSpeaker(final Speaker aSpeaker)
    {
        DatabaseUtil.updateSpeaker(aSpeaker);
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#deleteSpeaker(org.mhz.sit.entity.Speaker, javafx.collections.ObservableList)
     */
    @Override
    public void deleteSpeaker(final Speaker aSpeaker,
                              final ObservableList<Speaker> aObservableList)
    {
        DatabaseUtil.deleteSpeaker(aSpeaker, aObservableList);  
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#getOrderOfSpeakers()
     */
    @Override
    public List<SpeakerOrder> getOrderOfSpeakers()
    {
        final List<SpeakerOrder> orderOfSpeakers = mConfigureSpeakersDAO.getOrderOfSpeakers();   
        
        return orderOfSpeakers;
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#getOffTopicOrder()
     */
    @Override
    public List<SpeakerOffTopicOrder> getOffTopicOrder()
    {
        final List<SpeakerOffTopicOrder> offTopicOrder = mConfigureSpeakersDAO.getOffTopicOrder();   
        
        return offTopicOrder;
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#addToSpeakerOrder(org.mhz.sit.entity.SpeakerOrder, javafx.collections.ObservableList)
     */
    @Override
    public void addToSpeakerOrder(final SpeakerOrder aSpeaker,
                                  final ObservableList<SpeakerOrder> aObservableList)
    {
        DatabaseUtil.addToSpeakerOrder(aSpeaker, 
                                       SpeakerUtil.getObservableOrderOfSpeakersList());
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#deleteSpeakerOrder(org.mhz.sit.entity.SpeakerOrder, javafx.collections.ObservableList)
     */
    @Override
    public void deleteSpeakerOrder(final SpeakerOrder aSpeaker,
                                   final ObservableList<SpeakerOrder> aObservableList)
    {
        DatabaseUtil.deleteSpeakerOrder(aSpeaker, aObservableList);          
    }

    /* (non-Javadoc)
     * @see org.mhz.sit.service.SpeakerService#moveSpeakerTo(org.mhz.sit.entity.BaseSpeaker, javafx.collections.ObservableList, javafx.collections.ObservableList)
     */
    @Override
    public void moveSpeaker(final BaseSpeaker aSpeaker,
                              final ObservableList<SpeakerOrder> aObservableSpeakerOrderList,
                              final ObservableList<SpeakerOffTopicOrder> aObservableOffTopicOrderList)
    {
        DatabaseUtil.moveSpeakerTo(aSpeaker, aObservableSpeakerOrderList, aObservableOffTopicOrderList);
    }
}
